import java.util.Scanner;
import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Question10 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        int n = in.nextInt();
        int k = in.nextInt();

        // int[][] edges = new int[n - 1][2];
        // for (int i = 0; i < n - 1; i++) {
        //     int temp1 = in.nextInt() - 1;
        //     int temp2 = in.nextInt() - 1;

        //     edges[i][0] = Math.min(temp1, temp2);
        //     edges[i][1] = Math.max(temp1, temp2);
        // }

        Map<Integer, List<Integer>> map = new HashMap<>();

        for (int i = 0; i < n - 1; i++) {
            int temp1 = in.nextInt() - 1;
            int temp2 = in.nextInt() - 1;   

            if (map.get(temp1) == null) {
                List<Integer> list = new ArrayList<>();
                list.add(temp2);

                map.put(temp1, list);
            }
            else {
                List<Integer> list = map.get(temp1);
                list.add(temp2);
            }


            if (map.get(temp2) == null) {
                List<Integer> list = new ArrayList<>();
                list.add(temp1);

                map.put(temp2, list);
            }
            else {
                List<Integer> list = map.get(temp2);
                list.add(temp1);

                map.put(temp2, list);
            }
        }


        // Arrays.sort(edges, (int[] a, int[] b) -> {
        //     if (a[0] != b[0]) {
        //         return a[0] - b[0];
        //     }
        //     else {
        //         return a[1] - b[1];
        //     }
        // });


        long ret = 0;

        long[] dp = new long[n];
        boolean[] flag = new boolean[n];

        // 广度优先搜索
        Queue<Integer> queue = new LinkedList<>();
        queue.add(0);

        while (!queue.isEmpty()) {
            int node = queue.poll();

            List<Integer> temp = map.get(node);

            int size = queue.size();
            for (int i : temp) {
                if (flag[i]) {
                    continue ;
                }

                 
                queue.add(i);
                dp[i] = dp[node] + 1;
            }

            if (queue.size() != size) {
                flag[node] = true;
            }

            // for (int i = 0; i < n - 1; i++) {
            //     if (edges[i][0] == -1) {
            //         continue ;
            //     }

            //     if (edges[i][0] == node) {
            //         flag[node] = true;

            //         int child = edges[i][1];
            //         dp[child] = dp[node] + 1;

            //         edges[i][0] = -1;
            //         edges[i][1] = -1;

            //         queue.add(child);
            //     }
            //     else if (edges[i][1] == node) {
            //         flag[node] = true;

            //         int child = edges[i][0];
            //         dp[child] = dp[node] + 1;

            //         edges[i][0] = -1;
            //         edges[i][1] = -1;

            //         queue.add(child);
            //     }
            // }
        }


        // dfs(0, dp, edges, flag);

        // for (int i = 0; i < n; i++) {
        //     System.out.print(flag[i] + " ");
        // }
        // System.out.println(Arrays.toString(dp));

        for(int i = 0; i < n; i++) {
            if (dp[i] > k) {
                continue ;
            }

            if (flag[i]) {
                ret++;
            }

            if (!flag[i]) {
                ret++;

                ret += k - dp[i];
            }
        }

        System.out.println(ret);
    }

    public static void dfs (int node, long[] dp, int[][] edges, boolean[] flag) {
        for (int i = 0; i < edges.length; i++) {
            if (edges[i][0] == -1) {
                continue ;
            }

            if (edges[i][0] == node) {
                flag[node] = true;

                int child = edges[i][1];
                dp[child] = dp[node] + 1;

                edges[i][0] = -1;
                edges[i][1] = -1;

                dfs(child, dp, edges, flag);
            }
            else if (edges[i][1] == node) {
                flag[node] = true;

                int child = edges[i][0];
                dp[child] = dp[node] + 1;

                edges[i][0] = -1;
                edges[i][1] = -1;

                dfs(child, dp, edges, flag);
            }
            
        }
    } 
}